package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type appConfig struct {
	Mysql
	Redis
}

type Mysql struct {
	User     string
	Port     int
	Host     string
	Password string
	Database string
}

type Redis struct {
	Host     string
	Port     int
	Password string
	Database int
}

var Config appConfig

func Init() {
	var err error
	viper.SetConfigFile("../appconfig/dev.yaml")
	err = viper.ReadInConfig()
	err = viper.Unmarshal(&Config)
	if err != nil {
		panic(err)
	}
	fmt.Println("Config:init success")
}
